package com.bite.springioc.Controller;


import cn.hutool.captcha.CaptchaUtil;
import cn.hutool.captcha.LineCaptcha;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.io.IOException;

@RequestMapping("/captcha")
@RestController
public class CaptchaController {

    @RequestMapping("/getCaptcha")
    public void getCaptcha(HttpServletResponse response) {
        //定义图形验证码的⻓和宽
        LineCaptcha lineCaptcha = CaptchaUtil.createLineCaptcha(200,
                100, 4, 150);
        //图形验证码写出，可以写出到⽂件，也可以写出到流
        lineCaptcha.write("./line.png");
        //输出code
        System.out.println("⽣成的验证码:" + lineCaptcha.getCode());
    }
}
